﻿using System.Collections.Generic;
using System.Windows.Forms;
using Sklad1_2.Add.Update;
using Sklad1_2.Data;
using Sklad1_2.Default;

namespace Sklad1_2.Add
{
    public partial class AddClient : Defaultform
    {
        public AddClient():base()
        {
            InitializeComponent();
            Init();
        }

        public override sealed void Init()
        {
            ABase.AddItemDBGridView(dataGridView1,Helper.QueryCustomer);
            Helper.Hidden(dataGridView1,0);
        }

        private void button1_Click(object sender, System.EventArgs e)
        {
            if (textBox1.Text.Length>0)
            {
                ABase.InsertValueCustomer(textBox1.Text,textBox2.Text,textBox3.Text,textBox4.Text);
                Init();
            }
            else
            {
                MessageBox.Show("Заполните все поля ввода!!!");
            }
        }

        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            data=new List<string>();
            Helper.Db2List(dataGridView1,e,ref data,0,1,2,3,4);
            UpdateClient aUpdateClient=new UpdateClient(data);
            aUpdateClient.FormClosed += Bind;
            aUpdateClient.ShowDialog();
        }
    }
}
